<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Vue.js"></script>
    <style>
        #overlay {
            background: rgba(0, 0, 0, 0.3);
            width: 100%;
            margin: auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }

        #center {
            background: #fff;
            border-radius: 5px;
            padding: 15px 0 30px 15px;
            width: 290px;
            height: 160px;
            position: fixed;
            margin: auto;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;

        }
    </style>
</head>

<body>
    <div class="box">
        <button @click="is_show=!is_show">log in</button>
        <div id="overlay" v-show="is_show" @click.self="is_show=!is_show">
            <!-- @click.stop 也可以阻止冒泡 @click.self 只点击自己才有用-->
            <div id="center" @click.stop>
                <label for="inp"> 用户名：</label><input type="text" id="inp">
                <button>log in</button>
            </div>
        </div>
    </div>
    <script>
        const obj = {
            data() {
                return {
                    is_show: false
                }
            }
        }
        Vue.createApp(obj).mount('.box');

    </script>
</body>

</html>